package com.zhejiangzhengyuan.municipal_common.entity.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author lin_ju
 * @create on 2019/12/1 告警事件图表
 */
@Data
@ApiModel(value = "告警时间统计", description = "对告警时间次数进行统计，封装Vo对象")
public class WarnEventChartVo {
  @ApiModelProperty("统计时间")
  private String time;

  @ApiModelProperty("封装统计类")
  private List<OriginCount> counts;

  public void addCounts(String origin, int count) {
    if (Objects.isNull(counts)) {
      counts = new ArrayList<>();
    }
    OriginCount originCount = new OriginCount();
    originCount.setCount(count);
    originCount.setDataOrigin(origin);
    counts.add(originCount);
  }

  @Data
  private static class OriginCount {
    @ApiModelProperty("数据来源")
    // 系统告警，系统新建,移动端上报
    private String dataOrigin;

    @ApiModelProperty("出现次数")
    private int count;
  }
}
